import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;


/**
 * @author liushan
 * Created by liushan on 2019-04-09.
 */
@WebServlet(urlPatterns = {"/exit"})
public class Exit extends HttpServlet {

    // curl -v http://localhost:8080/test/Servlet1
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {

        doPost(req,resp);
    }



    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");

        HttpSession session = req.getSession(true);
        session.getAttribute("users");
        session.invalidate();
        resp.sendRedirect("https://cas.dgut.edu.cn/logout?callback=http://localhost:8080/Login.jsp");
    }
}
